<!DOCTYPE html>
<html lang="zh">

<head>

    <!-- SITE TITTLE -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>课程展示</title>


    <!-- PLUGINS CSS STYLE -->
    <!-- <link href="plugins/jquery-ui/jquery-ui.min.css" rel="stylesheet"> -->
    <!-- Bootstrap -->
    <link rel="stylesheet" href="../plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../plugins/bootstrap/css/bootstrap-slider.css">
    <!-- Font Awesome -->
    <link href="../plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- Owl Carousel -->
    <link href="../plugins/slick-carousel/slick/slick.css" rel="stylesheet">
    <link href="../plugins/slick-carousel/slick/slick-theme.css" rel="stylesheet">
    <!-- Fancy Box -->
    <link href="../plugins/fancybox/jquery.fancybox.pack.css" rel="stylesheet">
    <link href="../plugins/jquery-nice-select/css/nice-select.css" rel="stylesheet">
    <!-- CUSTOM CSS -->
    <link href="../css/style.css" rel="stylesheet">


    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body class="body-wrapper">

<section>
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <nav class="navbar navbar-expand-lg navbar-light navigation">
                    <a class="navbar-brand" href="index">
                        <!-- <img src="images/logo.png" alt=""> -->
                    </a>
                    <button class="navbar-toggler" type="button" data-toggle="collapse"
                            data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
                            aria-expanded="false" aria-label="Toggle navigation">
                        <span class="navbar-toggler-icon"></span>
                    </button>
                    <div class="collapse navbar-collapse" id="navbarSupportedContent">
                        <ul class="navbar-nav ml-auto main-nav ">
                            <li class="nav-item">
                                <a class="nav-link" href="../index">学生主页</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="../courseList">课程展示</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="../newsList">学生资讯中心</a>
                            </li>

                            <li class="nav-item dropdown dropdown-slide">
                                <a class="nav-link dropdown-toggle" href="" data-toggle="dropdown"
                                   aria-haspopup="true" aria-expanded="false">
                                    个人中心 <span><i class="fa fa-angle-down"></i></span>
                                </a>
                                <!-- Dropdown list -->
                                <div class="dropdown-menu">
                                    <a class="dropdown-item" href="../study">课程学习</a>
                                    <a class="dropdown-item" href="../user">个人信息</a>
                                </div>
                            </li>
                        </ul>
                        <ul class="navbar-nav ml-auto mt-10">
                            <li class="nav-item">
                                <a class="nav-link login-button" href="../login">退出</a>
                            </li>
                        </ul>
                    </div>
                </nav>
            </div>
        </div>
    </div>
</section>
<!--===================================
=            Store Section            =
====================================-->
<section class="section bg-gray" id="app">
    <!-- Container Start -->
    <div class="container">
        <div class="row">
            <!-- Left sidebar -->
            <div class="col-md-12">
                <div class="product-details">

                    <h1 class="product-title" v-text="data.courseName"></h1>
                    <button class="btn btn-transparent btn-light offset-10" @click="addSelection()">
                        学习此课
                    </button>


                    <div class="content mt-5 pt-5">
                        <ul class="nav nav-pills  justify-content-center" id="pills-tab" role="tablist">
                            <li class="nav-item">
                                <a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-home"
                                   role="tab" aria-controls="pills-home" aria-selected="true">课程描述</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-profile"
                                   role="tab" aria-controls="pills-profile" aria-selected="false">课程信息</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-contact"
                                   role="tab" aria-controls="pills-contact" aria-selected="false">评价</a>
                            </li>
                        </ul>
                        <div class="tab-content" id="pills-tabContent">
                            <div class="tab-pane fade show active" id="pills-home" role="tabpanel"
                                 aria-labelledby="pills-home-tab">
                                <h3 class="tab-title">描述</h3>
                                <div v-text="data.courseInfo">

                                </div>
                            </div>
                            <div class="tab-pane fade" id="pills-profile" role="tabpanel"
                                 aria-labelledby="pills-profile-tab">
                                <h3 class="tab-title">课程信息</h3>
                                <table class="table table-bordered product-table">
                                    <tbody>
                                    <tr>
                                        <td>课程名字</td>
                                        <td v-text="data.courseName"></td>
                                    </tr>
                                    <tr>
                                        <td>课程学时</td>
                                        <td v-text="data.courseTime"></td>
                                    </tr>
                                    <tr>
                                        <td>授课教师</td>
                                        <td v-text="data.teacherName"></td>
                                    </tr>
                                    <tr>
                                        <td>教师学历</td>
                                        <td v-text="data.teacherEdu"></td>
                                    </tr>

                                    </tbody>
                                </table>
                            </div>
                            <div class="tab-pane fade" id="pills-contact" role="tabpanel"
                                 aria-labelledby="pills-contact-tab">
                                <h3 class="tab-title">选课学生课程评价</h3>
                                <div class="product-review">
                                    <div class="media" v-for="(item, index) in assess" :key="index">


                                        <div class="media-body">
                                            <!-- Ratings -->
                                            <div class="ratings">

                                            </div>
                                            <div class="name">
                                                <h5 v-text="item.studentName"></h5>
                                            </div>

                                            <div class="review-comment">
                                                <p v-text="item.assess">

                                                </p>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="review-submission">
                                        <h3 class="tab-title">评价单</h3>
                                        <!-- Rate -->

                                        <div class="review-submit">
                                            <form class="row" onsubmit="return false">


                                                <div class="col-12">
														<textarea name="assess" id="review" rows="10"
                                                                  class="form-control" placeholder="Message"
                                                                  v-model="newAssess"></textarea>
                                                </div>
                                                <div class="col-12">
                                                    <button type="submit" class="btn btn-main"
                                                            @click="addassess()">提交
                                                    </button>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>


        </div>
    </div>
    <!-- Container End -->
</section>
<!--============================
=            Footer            =
=============================-->

<!-- Footer Bottom -->
<footer class="footer-bottom">
    <!-- Container Start -->
    <div class="container">
        <div class="row">
            <div class="col-sm-6 col-12">
                <!-- Copyright -->
                <div class="copyright">
                    <p>慕随心 © 2019
                </div>
            </div>
        </div>
    </div>
    <!-- Container End -->
    <!-- To Top -->
    <div class="top-to">
        <a id="top" class="" href="#"><i class="fa fa-angle-up"></i></a>
    </div>
</footer>

<!-- JAVASCRIPTS -->
<script src="../plugins/jQuery/jquery.min.js"></script>
<script src="../plugins/bootstrap/js/popper.min.js"></script>
<script src="../plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="../plugins/bootstrap/js/bootstrap-slider.js"></script>
<!-- tether js -->
<script src="../plugins/tether/js/tether.min.js"></script>
<script src="../plugins/raty/jquery.raty-fa.js"></script>
<script src="../plugins/slick-carousel/slick/slick.min.js"></script>
<script src="../plugins/jquery-nice-select/js/jquery.nice-select.min.js"></script>
<script src="../plugins/fancybox/jquery.fancybox.pack.js"></script>
<script src="../plugins/smoothscroll/SmoothScroll.min.js"></script>
<!-- google map -->
<script
        src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCcABaamniA6OL5YvYSpB3pFMNrXwXnLwU&libraries=places"></script>
<script src="../plugins/google-map/gmap.js"></script>
<script src="../js/script.js"></script>
<script src="https://cdn.bootcss.com/axios/0.19.0-beta.1/axios.js"></script>
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
<script src="https://cdn.bootcss.com/bootbox.js/4.4.0/bootbox.min.js"></script>

<script>
    new Vue({
        el: "#app",
        data() {
            return {
                data: null,
                assess: null,
                newAssess: null
            }
        },
        created() {
            var id = /\d+/.exec(location.pathname);
            axios.get(" /onlineStudent/api/getCourse", {
                params: {
                    courseId: id[0]
                }
            }).then(response => (this.data = response["data"]["data"]));
            axios.get(" /onlineStudent/api/getSelectInfo", {
                params: {
                    courseId: id[0]
                }
            }).then(response => (this.assess = response["data"]["data"]))

        }, methods: {

            addassess: function () {
                var id = /\d+/.exec(location.pathname);
                if (this.newAssess == null) {
                    bootbox.alert({
                        buttons: {
                            ok: {
                                label: '知道了',
                                className: 'btn-outline-success'
                            }
                        },
                        message: "请输入内容"
                    });
                    return;
                }
                var _this = this;
                var data = new FormData();
                data.append("assess", this.newAssess);
                data.append("courseId", id[0]);
                axios.post(" /onlineStudent/api/addSelectAssess", data).then(response => bootbox.alert({
                    buttons: {
                        ok: {
                            label: '知道了',
                            className: 'btn-outline-success'
                        }
                    },
                    message: response["data"]["msg"],
                    callback: function () {
                        _this.reloadCourseInfo();
                    }
                }));
                this.newAssess=null;
            },
            reloadCourseInfo: function () {
                var id = /\d+/.exec(location.pathname);

                axios.get(" /onlineStudent/api/getSelectInfo", {
                    params: {
                        courseId: id[0]
                    }
                }).then(response => (this.assess = response["data"]["data"]))
            },
            addSelection: function () {
                var id = /\d+/.exec(location.pathname);
                var data = new FormData();
                data.append("courseId", id[0]);
                axios.post(" /onlineStudent/api/addSelection", data).then(response => bootbox.alert({
                    buttons: {
                        ok: {
                            label: '知道了',
                            className: 'btn-outline-success'
                        }
                    },
                    message: response["data"]["msg"]
                }))

            }
        }
    })

</script>


</body>

</html>